<extend name="Public/base"/>
<block name="style" >
    <link rel="stylesheet" href="__STATIC__/styles/vendors/bootstrap-table.css">
    <link rel="stylesheet" href="__STATIC__/styles/log.css">
    <link rel="stylesheet" href="__STATIC__/styles/vendors/bootstrap-select.min.css">
    <link rel="stylesheet" href="__STATIC__/styles/vendors/bootstrap-datetimepicker.min.css">
</block>
<block name="content">
    <div id="toolbar">
        <div class="control-group row">
            <div class="col-lg-8 col-md-8 col-sm-8 col-xs-8 right">
                <div class="controls">
                    <label class="control-label">操作时间:</label>
                    <div class="during-left during">
                        <div class='input-group date' id='datetimepicker1'>
                            <input type='text' class="form-control" name="begin_time"/>
                            <span class="input-group-addon">
                                <span class="glyphicon glyphicon-calendar"></span>
                            </span>
                        </div>

                    </div>
                    <div class="during-center during" style="line-height: 34px;text-align: center">
                        ——
                    </div>
                    <div class="during-right during">
                        <div class='input-group date' id='datetimepicker2'>
                            <input type='text' class="form-control" name="end_time"/>
                            <span class="input-group-addon">
                                            <span class="glyphicon glyphicon-calendar"></span>
                                        </span>
                        </div>
                    </div>
                </div>
            </div>

            <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4 right">
                <div class="controls">
                    <label class="control-label">用户:</label>
                    <div class="during-left during">
                        <input type='text' class="form-control" name="real_name"/>
                    </div>
                </div>
            </div>


        </div>

        <div class="control-group row">
            <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4 right">
                <div class="controls">
                    <label class="control-label">IP:</label>
                    <div class="during-left during">
                        <input type='text' class="form-control" name="IP"/>
                    </div>
                </div>
            </div>
            <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4 right">
                <div class="controls">
                    <label class="control-label">功能点:</label>
                    <div class="during-left during">
                        <input type='text' class="form-control" name="func"/>
                    </div>
                </div>
            </div>

            <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4 right">
                <div class="controls">
                    <label class="control-label">描述:</label>
                    <div class="during-left during">
                        <input type='text' class="form-control" name="describe"/>
                    </div>
                </div>
            </div>

            <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4 right">
                <div class="controls">
                    <button type="button" class="btn btn-info btn-flat query">查询</button>
                </div>
            </div>
        </div>
    </div>

    <table id="table" data-toolbar="#toolbar"></table>


</block>

<block name="script">
    <script src="__STATIC__/scripts/vendors/bootstrap-select.min.js"></script>
    <script src="__STATIC__/scripts/vendors/bootstrap-table.js"></script>
    <script src="__STATIC__/scripts/vendors/moment.min.js"></script>
    <script src="__STATIC__/scripts/vendors/bootstrap-datetimepicker.min.js"></script>
    <script>

        var $table = $('#table');

        var TableInit = function(){
            var oTableInit = new Object();

            oTableInit.init = function(){
                $table.bootstrapTable({
                    formatLoadingMessage: function () {
                        return '正在努力地加载数据中，请稍候……';
                    },
                    formatRecordsPerPage: function (pageNumber) {
                        return '每页显示 ' + pageNumber + ' 条记录';
                    },
                    formatShowingRows: function (pageFrom, pageTo, totalRows) {
                        return '显示第 ' + pageFrom + ' 到第 ' + pageTo + ' 条记录，总共 ' + totalRows + ' 条记录';
                    },
                    formatSearch: function () {
                        return '搜索';
                    },
                    formatNoMatches: function () {
                        return '没有找到匹配的记录';
                    },
                    formatPaginationSwitch: function () {
                        return '隐藏/显示分页';
                    },
                    formatRefresh: function () {
                        return '刷新';
                    },
                    formatToggle: function () {
                        return '切换';
                    },
                    formatColumns: function () {
                        return '列';
                    },
                    url:"{:U('logList')}",
                    method:'get',
                    striped:true,
                    cache:false,
                    pagination:true,
                    sortable:false,
                    sortOrder:'asc',
                    sidePagination:'server',
                    queryParams:oTableInit.queryParams,
                    pageNumber:1,
                    pageSize:8,
                    pageList:[8,16,24],
                    uniqueId:'log_id',

                    columns:[
                        {
                            field:'operation_time',
                            title:'操作时间'
                        },
                        {
                            field:'real_name',
                            title:'用户'
                        },
                        {
                            field:'ip',
                            title:'IP'
                        },
                        {
                            field:'function',
                            title:'功能点'
                        },
                        {
                            field:'describe',
                            title:'描述'
                        }

                    ]
                });


                $(window).resize(function () {
                    $table.bootstrapTable('resetView');
                });

            };

            oTableInit.queryParams = function(params){
                var temp = {
                    limit:params.limit,
                    offset:params.offset,
                    begin_time:$('input[name=begin_time]').val(),
                    end_time:$('input[name=end_time]').val(),
                    real_name:$('input[name=real_name]').val(),
                    ip:$('input[name=IP]').val(),
                    func:$('input[name=func]').val(),
                    describe:$('input[name=describe]').val()
                };
                return temp;
            };

            return oTableInit;
        };


        $(function () {
            $('#datetimepicker1').datetimepicker({format: 'YYYY-MM-DD'});
            $('#datetimepicker2').datetimepicker({format: 'YYYY-MM-DD'});
            var oTable = new TableInit();
            oTable.init();

            $('.query').click(function () {
                $table.bootstrapTable('refresh');
            })

        });


    </script>
</block>